import wx

from utils import tracer
from shellPane import ShellPane
from configPane import ConfigPane
from plugins.base import plugin

class PythonShell(plugin.Plugin):
  def __init__(self):
    plugin.Plugin.__init__(self)

  def uninit(self):
    pass
  
  def createPane(self):
    if self._mainFrm is None:
      return None
    return ShellPane(self._mainFrm)
  
  def createConfigPane(self):
    if self._mainFrm is None:
      return None
    return ConfigPane(self._mainFrm)
  
  def createMenus(self):
    if self._mainFrm is None:
      return None
    
    menu = None

    if menu is None:
      menu = []

      # create file menu
      debug_menu = wx.Menu()

##      debug_menu_item_run_script = debug_menu.Append(-1, '&Run Script')
##      self._mainFrm.Bind(wx.EVT_MENU, self.onRunScript, debug_menu_item_run_script)
##
##      debug_menu_item_run_project = debug_menu.Append(-1, '&Run Project')
##      self._mainFrm.Bind(wx.EVT_MENU, self.onRunProject, debug_menu_item_run_project)

      menu.append(('&Debug', debug_menu))
  
    return menu
  
  def createToolbar(self):
    return None
  
##  def onRunScript(self, evt):
##    if self._pluginMgr is None or self._pane is None:
##      evt.Skip()
##
##    pluginInfo = self._pluginMgr.getPluginByName('DocumentManager')
##    if pluginInfo is None:
##      evt.Skip()
##
##    mod = pluginInfo.getModule()
##    if mod is None:
##      evt.Skip()
##
##    curDoc = mod.getCurrentDocument()
##    if curDoc is None:
##      evt.Skip()
##
##    self._pane.runFile(curDoc.getFilename())
##  ##  cmd = 'python %s' % curDoc.getFilename()
##  ##  import os
##  ##  os.system(cmd)
##
##  def onRunProject(self, evt):
##    pass
##


instance = None
def getInstance():
  global instance
  if instance is None:
    instance = createInstance()
  return instance

def createInstance():
  return PythonShell()

